module jade.tpl.test ;

/**
 * Jade Template Engin For D
 * https://github.com/visionmedia/jade
 * http://gool.googlecode.com/svn/trunk/fastcgi/jade/
 */

version(JADE_TPL_TEST):

import jade.tpl.Template , std.process;

pragma(lib, `pcre`);

void main(){
	Tpl_Factory.Init ;
	
	auto user_list	= Tpl_Factory.Create("UserList", "../example.jade" );
	
	user_list.assign("Jade4D test page", "page_title");
	
	user_list.assign(environment.toAA, "env");
	
	string[string] items ;
	items["1"] = "One";
	items["2"] = "Two";
	items["3"] = "Three";
	user_list.assign(items, "items");
	
	auto user = new User ;
	user_list.assign(user, "user");
	
	StopWatch sw;
	sw.start;
	string html = user_list.render ;
	sw.stop;
	Log("use %dms size:%dKb", sw.peek.msecs, html.length / 1024);
	Log("%s", html.length > 10240 ? html[0..10240] : html  );
}

private class User {
	int id	= 1983 ;
	bool login	= true ;
	bool admin	= false ;
	string name		= "Chang Long";
}